// 交易方式枚举
export const DeliveryMethod = {
  NONE: 0,
  FACE_TO_FACE: 1,
  MAIL: 2,
  BOTH: 3
};

// 议价选项枚举
export const BargainOption = {
  NO_BARGAIN: 1,
  ALLOW_BARGAIN: 2,
  NEGOTIABLE: 3
};

// 交易方式选项
export const deliveryMethodOptions = [
  { value: DeliveryMethod.FACE_TO_FACE, label: '面交' },
  { value: DeliveryMethod.MAIL, label: '邮寄' },
  { value: DeliveryMethod.BOTH, label: '两者都可' }
];

// 议价选项
export const bargainOptionOptions = [
  { value: BargainOption.NO_BARGAIN, label: '不议价' },
  { value: BargainOption.ALLOW_BARGAIN, label: '允许砍价' },
  { value: BargainOption.NEGOTIABLE, label: '可协商' }
];

// 从旧字段推断交易方式
export function getDeliveryMethodFromOldFields(data) {
  if (data.dealFace && data.dealMail) return DeliveryMethod.BOTH;
  if (data.dealFace) return DeliveryMethod.FACE_TO_FACE;
  if (data.dealMail) return DeliveryMethod.MAIL;
  return DeliveryMethod.NONE;
}

// 从旧字段推断议价选项
export function getBargainOptionFromOldFields(data) {
  if (data.noBargain) return BargainOption.NO_BARGAIN;
  if (data.allowBargain) return BargainOption.ALLOW_BARGAIN;
  return BargainOption.NEGOTIABLE;
}